Skip to content

feat(tx_cache): surface auth token retrieval errors#116

Open
init4samwise wants to merge 3 commits intomainfrom
samwise/eng-1798-surface-auth-token-error
Open

feat(tx_cache): surface auth token retrieval errors#116
init4samwise wants to merge 3 commits intomainfrom
samwise/eng-1798-surface-auth-token-error

Conversation

@init4samwise
Copy link

Summary

Surfaces auth token retrieval errors instead of silently using an empty string.

Changes

  • Add BuilderTxCacheError enum with:
    • TokenRetrieval variant wrapping watch::error::RecvError
    • TxCache variant wrapping existing TxCacheError
  • Replace unwrap_or_else with ? operator to propagate errors
  • Update local Result type alias to use BuilderTxCacheError

Breaking Change

This changes the return type from signet_tx_cache::error::Result to a new local Result type. Consumers will need to handle the new BuilderTxCacheError type.

Why

Per the ticket: "Right now, an empty string is used if the token retrieval fails, placing the responsibility of returning an appropriate error on the service being called. We should wrap the original error type, and add a variant that points out that there was a problem retrieving the token instead, surfacing the inner Recv error."

Closes ENG-1798

init4samwise and others added 2 commits February 6, 2026 16:40
ENG-1798: Add BuilderTxCacheError enum to properly surface auth token
retrieval failures instead of silently using an empty string.

Changes:
- Add BuilderTxCacheError with TokenRetrieval variant wrapping RecvError
- Add TxCache variant wrapping existing TxCacheError
- Replace unwrap_or_else with ? operator to propagate errors
- Update local Result type alias to use BuilderTxCacheError

This is a breaking change for consumers that expect the old Result type,
but surfaces the actual error cause for better debugging.
Copy link
Member

Evalir commented Feb 6, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Evalir Evalir requested review from Evalir and prestwich and removed request for prestwich February 6, 2026 17:05
@Evalir Evalir requested review from Fraser999 and prestwich February 6, 2026 17:50
Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BuilderTxCacheError::TxCache(TxCacheError::Reqwest(err)) issue is a blocker I think.


impl From<reqwest::Error> for BuilderTxCacheError {
fn from(err: reqwest::Error) -> Self {
BuilderTxCacheError::TxCache(TxCacheError::Reqwest(err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By not using from, we unconditionally make this a TxCacheError::Reqwest error. Using from means we'll set it to whichever of TxCacheError::NotFound, TxCacheError::NotOurSlot or TxCacheError::Reqwest is appropriate,

Suggested change
BuilderTxCacheError::TxCache(TxCacheError::Reqwest(err))
BuilderTxCacheError::TxCache(TxCacheError::from(err))

use tracing::instrument;

/// Result type for [`BuilderTxCache`] operations.
pub type Result<T> = std::result::Result<T, BuilderTxCacheError>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub type Result<T> = std::result::Result<T, BuilderTxCacheError>;
pub type Result<T> = core::result::Result<T, BuilderTxCacheError>;

Comment on lines +18 to +21
assert!(matches!(
bundles,
BuilderTxCacheError::TxCache(TxCacheError::NotOurSlot)
));
Copy link
Contributor

@Fraser999 Fraser999 Feb 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this matches the new behaviour, but the test is ignored, so not picked up in CI.

#[derive(Debug, Error)]
pub enum BuilderTxCacheError {
/// Failed to retrieve the authentication token.
#[error("failed to retrieve auth token: {0}")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this isn't a "failed to retrieve" right? this error is permanent and persistent, and implies something has gone wrong with the background auth task resulting in the sender being dropped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants